home *** CD-ROM | disk | FTP | other *** search
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Graphics;
-
- class BattleScreen extends Canvas implements CommandListener {
- private Fight parent;
- private static final Command[] COMMANDS = new Command[]{new Command("Fight", 4, 1), new Command("Exit game", 4, 1)};
- private int showY = 0;
- private int level = 0;
-
- public BattleScreen(Fight var1) {
- this.parent = var1;
- ((Displayable)this).addCommand(COMMANDS[0]);
- ((Displayable)this).addCommand(COMMANDS[1]);
- ((Displayable)this).setCommandListener(this);
- }
-
- public void commandAction(Command var1, Displayable var2) {
- if (var1 == COMMANDS[0]) {
- this.parent.restart();
- } else {
- this.parent.destroyApp(true);
- }
-
- }
-
- public void setLevel(int var1) {
- this.level = var1 % 6;
- }
-
- public void keyPressed(int var1) {
- switch (var1) {
- case -60:
- if (this.showY > 10 - this.level * 30) {
- this.showY -= 10;
- }
- break;
- case -59:
- if (this.showY < 110 - this.level * 30) {
- this.showY += 10;
- }
- }
-
- this.checkRange();
- ((Canvas)this).repaint();
- }
-
- public void checkRange() {
- if (this.showY < 10 - this.level * 30) {
- this.showY = 10 - this.level * 30;
- }
-
- if (this.showY > 110 - this.level * 30) {
- this.showY = 110 - this.level * 30;
- }
-
- }
-
- public void paint(Graphics var1) {
- var1.setColor(255, 255, 255);
- var1.fillRect(0, 0, 101, 80);
- var1.setColor(0);
-
- for(int var2 = 1; var2 < 6; ++var2) {
- var1.drawImage(Fight.faces[Fight.players[6 - var2]], 76, 30 * (var2 + this.level - 1) + 2 * (var2 + this.level - 1) + 5 + this.showY - 95, 20);
- }
-
- if (this.showY == 110 - this.level * 30) {
- var1.drawString("Level: " + this.level, 25, 4, 20);
- }
-
- var1.drawString("vs.", 47, 42 + this.showY, 20);
- var1.drawImage(Fight.faces[Fight.players[0]], 7, 37 + this.showY, 20);
- }
- }
-